import type { ApiPagination, ApiPaginationParams } from '#types/utils'
import { requestClient } from '../request'
import type {
    goodsInformationItemForm,
    goodsInformationPageListItem
} from './model/goodsInformationModel'

// 渠道管理
export default class GoodsInformationApi {
    static get inst() {
        return GoodsInformationApi._inst || (GoodsInformationApi._inst = new GoodsInformationApi())
    }
    private static _inst: GoodsInformationApi
    add(params: Partial<goodsInformationItemForm>) {
        return requestClient.post<null>('/goods/add', params)
    }
    delete(ids: Array<number | string>) {
        return requestClient.delete<null>(`/goods/delete/${ids}`)
    }
    details(id: number | string) {
        return requestClient.get<goodsInformationPageListItem>(`/goods/${id}`)
    }

    edit(id: number | string, params: Partial<goodsInformationItemForm>) {
        return requestClient.put<null>(`/goods/edit/${id}`, params)
    }
    /**
     * 站点管理分页
     * @param params
     */
    getPageList(params: ApiPaginationParams<{ username?: string }>) {
        return requestClient.get<ApiPagination<goodsInformationPageListItem>>('/goods/index', {
            params
        })
    }
}
